#ifndef MAP_H
#define MAP_H

#include "common.h"

typedef struct tagMapElemData
{
	unsigned char blank;
	unsigned char elemindex;
	unsigned char elemtype;
} MAPELEMDATA , *LPMAPELEMDATA;

typedef struct tagMapData
{
	unsigned int Offset;
	unsigned char BlankW;
	unsigned char Elemtype;
	unsigned char Elemindex;
	SDL_Surface* Image;
} MAPDATA ,*LPMAPDATA;

typedef struct tagMapUpLevel
{
	unsigned char ID;
	unsigned char Type;
	int PX;
	unsigned int Current;
	unsigned int First;
	int SX;
} MAPUPLEVEL;

class Map
{
public:
	Map(void);
	~Map(void);
	BOOL LoadMap(int FromStream = 0);
	void KeyUp();
	void KeyDown();
	void KeyLeft();
	void KeyRight();
	void KeyLL();
	void KeyRR();
	void KeyEnter();
	void KeyEsc();
	void KeyFly();
	void RefreshMap();
public:
	SDL_Surface* PlayerImg[6];
private:
	BOOL MapStop();
	BOOL LoadData();
	BOOL InImage();
	SDL_Surface* LoadMapImage(unsigned char, unsigned char);
	void CalcElemIndex();
	void DrawRoom();
	void DrawPlayer();
	void DrawMap();
	void PushStack();
private:
	vector<MAPDATA> MapDataTable;
	vector<MAPUPLEVEL> MapStack;
	unsigned char MapType, MapID;
	unsigned char PlayerDir;
	int PlayerX, ScreenX, ScreenXMax;
	unsigned int CurrentElem, FirstElem;
};


#endif